import instance from "./request";
import qs from "qs";
//登录请求接口
export const adminLoginAPI = (
  data: AdminData
): PromiseData<AdminLoginResData> => instance.post(`/admin/login`, data);

//获取当前登录用户信息

export const adminInfoAPI = (): PromiseData<UserInfoData> =>
  instance.get(`/admin/info`);

//根据用户名或姓名分页获取用户列表
export const getAdminListAPI = (
  params: getAdminListParams
): PromiseData<AdminListParams> => instance.get("/admin/list", { params });
//获取所有角色列表
export const getAdminAllRoleListAPI = (): PromiseData<getAdminRoleAPIData[]> =>
  instance.get("/role/listAll");
//获取指定用户角色
export const getAdminRoleAPI = (
  adminId: number
): PromiseData<getAdminRoleAPIData[]> => instance.get(`/admin/role/${adminId}`);

// 给用户分配角色(queryString参数(post第三个参数是qs参数))
export const getAdminRoleUpdateAPI = (
  data: RoleUpdateParams
): PromiseData<any> =>
  instance.post(`/admin/role/update`, null, { params: data });
//或者======
// export const getAdminRoleUpdateAPI = (
//   data: RoleUpdateParams
// ): PromiseData<any> => instance.post(`/admin/role/update`, qs.stringify(data));
// 修改指定用户信息
//或者===
// export const getAdminRoleUpdateAPI = (
//   data: RoleUpdateParams
// ): PromiseData<any> =>
//   instance.post(`/admin/role/update`, 'adminId=1&roleIds=1,2,3');


//修改用户信息
export const getAdminUpdateAPI = (
  data: IdialogruleForm,
  id: number
): PromiseData<any> => instance.post(`/admin/update/${id}`, data);

//首页可视化数据请求
export const getAdminIndexDataAPI = (): PromiseData<getAdminIndexDataAPIData> =>
  instance.get(`http://kumanxuan1.f3322.net:8360/admin/stat`);
